package com.gzedu.module.faced.curd.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.gzedu.module.faced.curd.CurdListFacade;
import com.gzedu.module.modle.curd.CurdList;
import com.gzedu.module.service.curd.ICurdListService;

@Service
public class CurdListFacadeImpl implements CurdListFacade{
	@Autowired
	private ICurdListService curdListService;

	public boolean insert(CurdList curdList) {
		// TODO Auto-generated method stub
		return curdListService.insert(curdList) > 0;
	}
	
	/**
	 * 查询通用列表的信息
	 * @param curdList
	 * @return
	 */
	public List<Map<String,Object>> selectByFormId(CurdList curdList){
		return curdListService.selectByFormId(curdList);
	}

	public List<CurdList> getByListId(CurdList curdList) {
		// TODO Auto-generated method stub
		return curdListService.getByListId(curdList);
	}

	public List<Map<String,Object>> getByFormId(String curd_form_id) {
		// TODO Auto-generated method stub
		List<Map<String,Object>> res = new ArrayList<Map<String,Object>>();
		
		CurdList curdList = new CurdList();
		curdList.setCurd_form_id(curd_form_id);
		List<CurdList> list = curdListService.getByFormId(curdList);
		if(list != null && list.size() > 0){
			for(CurdList curdLists : list){
				StringBuffer str = new StringBuffer();
				str.append(curdLists.getCurd_list_id()).append(",").append(curdLists.getFiled_name())
					.append(",").append(curdLists.getList_column()).append(",").append(curdLists.getPosition())
					.append(",").append(curdLists.getIs_show());
				Map<String,Object> map = new HashMap<String,Object>();
				map.put("curdList", str.toString());
				res.add(map);
			}
		}
		return res;
	}
}
